{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "95c844b1",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "list一般方法/函数的所有的使用场景及案例，方法如：\n",
    "1.append()\n",
    "2.pop()\n",
    "3.count() \n",
    "4.index() \n",
    "5.extend() \n",
    "6.sort() ...\n",
    "list 高级方法 1.copy() 复制不等于复制，复制课等价于切片 2.enu\n",
    "课本练习\n",
    "练习\n",
    "vowels = ['a','e','i','y','s'] word "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b2a67ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "user_data = \"chensimin\"\n",
    "user_password = \"123456\"\n",
    "username = input(\"请输入正确的账号：\")\n",
    "password = input(\"请输入正确的密码：\")\n",
    "for i in range(1):\n",
    "    if user_name == name and pa_wd == password:\n",
    "        print(\"enter\")\n",
    "        break\n",
    "        \n",
    "Alipay = input(\"请输入您的支付宝余额\")\n",
    "info = '''------ goods detail------\n",
    "编号1,商品名称:%s,商品的价格:%s\n",
    "goods_list = [('衣服',250),('裤子',150),('袜子',50),('鞋子'，300)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f9d9f31f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的支付宝余额800\n",
      "------ goods detail------\n",
      "编号0，商品名称:粉,商品的价格:底 元\n",
      "编号1，商品名称:耳,商品的价格:机 元\n",
      "编号2，商品名称:卫,商品的价格:衣 元\n",
      "编号3，商品名称:奶,商品的价格:茶 元 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# 1.商品信息\n",
    "goods_list = [\"粉底液 , 300\",\"耳机, 200\",\"卫衣, 200\",\"奶茶  , 15\"]\n",
    "user_shopping_list = []\n",
    "Alipay = input(\"请输入您的支付宝余额\")\n",
    "info = '''------ goods detail------\n",
    "编号0，商品名称:%s,商品的价格:%s 元\n",
    "编号1，商品名称:%s,商品的价格:%s 元\n",
    "编号2，商品名称:%s,商品的价格:%s 元\n",
    "编号3，商品名称:%s,商品的价格:%s 元 \n",
    "'''%(goods_list[0][0],goods_list[0][1],\n",
    "    goods_list[1][0],goods_list[1][1],\n",
    "    goods_list[2][0],goods_list[2][1],\n",
    "    goods_list[3][0],goods_list[3][1],)\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "01f709bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"stu10003\" in info_03)\n",
    "if \"stu10006\" in info_03:\n",
    "    print(info_03[\"stu10006\"])\n",
    "else:\n",
    "    print(\"查询的key不存在\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b0552f67",
   "metadata": {},
   "outputs": [],
   "source": [
    "users = [\n",
    "    [\"chensimin\",19,\"students\",10001],\n",
    "    [\"xiaoming\",26,\"IT\",10002]\n",
    "    \n",
    "]\n",
    "# 试对比：\n",
    "users_dict = {\n",
    "    \"chensimin\":[19,\"student\",10001],\n",
    "    \"xiaoming\":[26,\"IT\",10002]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "11554fac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaoming', 26, 'IT', 10002]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查找\n",
    "users[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7eba73a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 'student', 10001]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users_dict[\"chensimin\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04f2e93b",
   "metadata": {},
   "source": [
    "字典的增、删、改、查\n",
    "1.字典的增加(和字典的第三种创建方式一致)：\n",
    "  info_03[\"stu10004\"] = \"zhichao\"\n",
    "2.字典的查询\n",
    "  info_03[key_name]\n",
    "  注意： 正确的查询方式，应该先查询key是否存在字典当中，如下：\n",
    "  key_name in info_03 ## 查看是否存在,如果存在，返回结果为 True ，不存在为 False\n",
    "  info_03[key_name]\n",
    "3.字典的修改\n",
    "  查询key是否存在\n",
    "  修改key的值\n",
    "  例如： 修改info_03中stu10003的值为Alex, if \"stu10003\" in info_03 : info_03 [\"stu10003\"] = \"Alex\"\n",
    "字典的删除\n",
    "1.pop(key) 2.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ad8343e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
